<?php

require_once("../../controllers/init.php");
require_once($FILE_SYSTEM_ROOT."/controllers/authentication.php");

$personID = 0;

if (isset($_POST['personID']))
	$personID = $_POST['personID'];

$person = new Person($personID);
// if a new person, get the new PersonID
if($personID==0)
	$personID=$person->getID();
?>

<div id="people-edit-heading">Edit Person</div>
<input type="hidden" id="people-edit-value-id" value="<?php echo $personID; ?>"></input>

<div class="people-edit-title">Surname</div>
<div class="people-edit-surname"><input type="text" class="people-edit-value-text" id="people-edit-value-surname" value="<?php echo $person->getSurname();?>"></input></div>
<div class="clearboth"></div>

<div class="people-edit-title">First Name</div>
<div class="people-edit-firstname"><input type="text" class="people-edit-value-text" id="people-edit-value-firstname" value="<?php echo $person->getFirstName();?>"></input></div>
<div class="clearboth"></div>

<div class="people-edit-title">Emails</div>
<div class="people-edit-emails"><?php foreach( $person->getEmails() as $email) echo "<div><div class=\"removeEmailIcon\" id=\"".$email."\"></div><div class=\"people-edit-displayemail\">".$email."</div></div><div class=\"clearboth\"></div>";?><div class="addEmailIcon"></div><div id="people-edit-add-email"><input type="text" class="people-edit-value-text" id="people-edit-value-add-email"></input></div></div>
<div class="clearboth"></div>

<div class="people-edit-title">Groups</div>
<div class="people-edit-groups"><?php foreach( $person->getGroups() as $group) echo "<div><div class=\"removeGroupIcon\" id=\"".$group."\"></div><div class=\"people-edit-displaygroup\">".$GROUPS[$group]."</div></div><div class=\"clearboth\"></div>";?><div class="addGroupIcon"></div><div id="people-edit-add-group">Add</div></div>
<div class="clearboth"></div>

<div class="people-edit-title">Telephones</div>
<div class="people-edit-telephones"><?php foreach( $person->getTelephones() as $telephone) echo "<div><div class=\"removeTelephoneIcon\" id=\"".$telephone."\"></div><div class=\"people-edit-displaytelephone\">".$telephone."</div></div><div class=\"clearboth\"></div>";?><div class="addTelephoneIcon"></div><div id="people-edit-add-telephone"><input type="text" class="people-edit-value-text" id="people-edit-value-add-telephone"></input></div></div>
<div class="clearboth"></div>

<div class="people-edit-title">Addresses</div>
<div class="people-edit-addresses"><?php foreach( $person->getAddresses() as $address) echo "<div><div class=\"removeAddressIcon\" id=\"".$address->getAddressID()."\"></div><div class=\"people-edit-displayaddress\">".$address->getAddress1()."</div></div><div class=\"clearboth\"></div>";?><div class="addAddressIcon"></div><div id="people-edit-add-address">Add</div></div>
<div class="clearboth"></div>




<div class="clearboth"></div>

<?php require($FILE_SYSTEM_ROOT."/views/menus/people-edit-menu.php"); ?>


